package com.stylefeng.guns.modular.system.warpper;

import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import com.stylefeng.guns.core.shiro.ShiroKit;

import java.util.List;
import java.util.Map;

/**
 * 学生信息的包装类
 *
 * @author celing
 * @date 2018年9月25日 下午13:40:00
 */
public class StudentInfoWarpper extends BaseControllerWarpper {

    public StudentInfoWarpper(List<Map<String, Object>> list) {
        super(list);
    }

    @Override
    protected void warpTheMap(Map<String, Object> map) {
        map.put("creator", ConstantFactory.me().getUserNameById((Integer)map.get("ownerID")));
        map.put("distributor", ConstantFactory.me().getUserNameById((Integer)map.get("distUserID")));

        if(!ShiroKit.isAdmin()) {
            String phone = (String)(map.get("studentPhone"));
            map.put("studentPhone", "****" + phone.substring(phone.length()-7,phone.length()));
            String qq = (String)(map.get("qq"));
            map.put("qq", "****" + qq.substring(qq.length()/2));
            String weixin = (String)(map.get("weixin"));
            map.put("weixin", "****" + weixin.substring(weixin.length()/2));
        }

    }
}
